import { Direction, Difficulty, FoodType, GameSettings } from '../types/game';

export const GAME_SETTINGS = {
  GRID_SIZE: 20,
  CELL_SIZE: 20,
  INITIAL_SNAKE_LENGTH: 3,
  GAME_TICK: 50,
  COMBO_TIMEOUT: 3000,
  INVINCIBILITY_DURATION: 5000, // 5秒的无敌时间
  WALL_HIT_SHAKE_DURATION: 300,
  FOOD_TYPES: {
    [FoodType.NORMAL]: { probability: 0.7, points: 1 },
    [FoodType.GOLDEN]: { probability: 0.2, points: 2 },
    [FoodType.RAINBOW]: { probability: 0.1, points: 3 }
  }
};

export const DIFFICULTY_SETTINGS: Record<Difficulty, GameSettings> = {
  [Difficulty.EASY]: {
    gridSize: GAME_SETTINGS.GRID_SIZE,
    cellSize: GAME_SETTINGS.CELL_SIZE,
    initialSnakeLength: GAME_SETTINGS.INITIAL_SNAKE_LENGTH,
    baseSpeed: 300,
    maxSpeed: 200,
    speedIncrementScore: 10,
    speedIncrementPercent: 10,
    wallHits: 5
  },
  [Difficulty.MEDIUM]: {
    gridSize: GAME_SETTINGS.GRID_SIZE,
    cellSize: GAME_SETTINGS.CELL_SIZE,
    initialSnakeLength: GAME_SETTINGS.INITIAL_SNAKE_LENGTH,
    baseSpeed: 250,
    maxSpeed: 150,
    speedIncrementScore: 8,
    speedIncrementPercent: 15,
    wallHits: 3
  },
  [Difficulty.HARD]: {
    gridSize: GAME_SETTINGS.GRID_SIZE,
    cellSize: GAME_SETTINGS.CELL_SIZE,
    initialSnakeLength: GAME_SETTINGS.INITIAL_SNAKE_LENGTH,
    baseSpeed: 200,
    maxSpeed: 100,
    speedIncrementScore: 5,
    speedIncrementPercent: 20,
    wallHits: 1
  }
};

export const CANVAS_SIZE = GAME_SETTINGS.GRID_SIZE * GAME_SETTINGS.CELL_SIZE;
export const FOOD_DURATION = 10000; // 10 seconds

export const FOOD_PROBABILITIES = {
  NORMAL: 0.8,
  GOLDEN: 0.15,
  RAINBOW: 0.05,
};

export const FOOD_SCORES = {
  NORMAL: 1,
  GOLDEN: 3,
  RAINBOW: 5,
};

export const COLORS = {
  BACKGROUND: '#000000',
  GRID: '#1a1a1a',
  SNAKE: {
    NORMAL: '#00ff00',
    HIT: '#ff0000',
    INVINCIBLE: '#ffd700'
  },
  FOOD: {
    NORMAL: '#ff0000',
    GOLDEN: '#ffd700',
    RAINBOW: '#ff00ff'
  }
};

export const COMBO_MULTIPLIERS = {
  1: 1,  // 基础分数
  2: 2,  // 2连击
  3: 3,  // 3连击
  4: 4,  // 4连击
  5: 5   // 5连击及以上
}; 